package com.cskaoyan.shopping.converter;

import com.cskaoyan.mall.dto.ProductDetailDto;
import com.cskaoyan.shopping.dal.entitys.Item;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 创建日期: 2022/05/19 15:45
 *
 * @author yangfan
 */
@Service
@Mapper(componentModel = "spring")
public interface ProductDetailConverter {
    @Mappings({
            @Mapping(source = "id",target = "productId"),
            @Mapping(source = "title",target = "productName"),
            @Mapping(source = "price",target = "salePrice"),
            @Mapping(source = "sellPoint",target = "subTitle")
    })
    ProductDetailDto item2DetailDto(Item item);

    List<ProductDetailDto> item2DetailDtos(List<Item> items);
}
